%%%% RLDM Macros (LaTex)
%%%% Style File
%%%% March 2013
%%%% This has been purloined almost wholesale from nips10submit_e
%%%% There are minor changes for RLDM purposes

% This file can be used with Latex2e whether running in main mode, or
% 2.09 compatibility mode.
%
% If using main mode, you need to include the commands
%             \documentclass{article}
%             \usepackage{rldmsubmit,times}
% as the first lines in your document.  Or, if you do not have Times
% Roman font available, you can just use
%             \documentclass{article}
%             \usepackage{rldmsubmit}
% instead.
%

% Change the overall width of the page.  If these parameters are
%       changed, they will require corresponding changes in the
%       maketitle section.
%
\usepackage{eso-pic} % used by \AddToShipoutPicture 

\renewcommand{\topfraction}{0.95}   % let figure take up nearly whole page
\renewcommand{\textfraction}{0.05}  % let figure take up nearly whole page

% Define rldmfinal, set to true if rldmfinalcopy is defined  
\newif\ifrldmfinal
\rldmfinaltrue
\def\rldmfinalcopy{\rldmfinaltrue}
\font\rldmtenhv  = phvb at 8pt % *** IF THIS FAILS, SEE rldm10submit_e.sty ***

% Specify the dimensions of each page

%\setlength{\paperheight}{11in}
%\setlength{\paperwidth}{8.5in}

\newlength{\rldmFPmargin}
\setlength{\rldmFPmargin}{1.5cm}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}

\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-2\rldmFPmargin}
\setlength{\oddsidemargin}{\rldmFPmargin}
\addtolength{\oddsidemargin}{-1in}
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\addtolength{\textheight}{-2\rldmFPmargin}
\setlength{\topmargin}{\rldmFPmargin}
\addtolength{\topmargin}{-1in}

%\textheight 23 true cm       % Height of text (including footnotes & figures)
%\textwidth 14 true cm        % Width of text line.
\widowpenalty=10000
\clubpenalty=10000

\thispagestyle{empty} %\pagestyle{empty}
\flushbottom \sloppy

% We're never going to need a table of contents, so just flush it to 
% save space --- suggested by drstrip@sandia-2
\def\addcontentsline#1#2#3{}

% Title stuff, taken from deproc.
\def\maketitle{\par 
\begingroup
   \def\thefootnote{\fnsymbol{footnote}}
   \def\@makefnmark{\hbox to 0pt{$^{\@thefnmark}$\hss}} % for perfect author
                                                        % name centering
%   The footnote-mark was overlapping the footnote-text,
%   added the following to fix this problem               (MK)
   \long\def\@makefntext##1{\parindent 1em\noindent
                            \hbox to1.8em{\hss $\m@th ^{\@thefnmark}$}##1}
   \@maketitle \@thanks
\endgroup
\setcounter{footnote}{0}
\let\maketitle\relax \let\@maketitle\relax
\gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}

% The toptitlebar has been raised to top-justify the first page

% Title (includes both anonimized and non-anonimized versions)
\def\@maketitle{\vbox{\hsize\textwidth
\linewidth\hsize \vskip 0.1in \toptitlebar \centering
{\LARGE\bf \@title\par}  \bottomtitlebar % \vskip 0.1in %  minus
\ifrldmfinal
   \def\And{\end{tabular}\hfil\linebreak[0]\hfil
            \begin{tabular}[t]{c}\bf\rule{\z@}{24pt}\ignorespaces}% 
  \def\AND{\end{tabular}\hfil\linebreak[4]\hfil
            \begin{tabular}[t]{c}\bf\rule{\z@}{24pt}\ignorespaces}% 
    \begin{tabular}[t]{c}\bf\rule{\z@}{24pt}\@author\end{tabular}% 
\else 
     \begin{tabular}[t]{c}\bf\rule{\z@}{24pt}
Anonymous Author(s) \\
Affiliation \\
Address \\
\texttt{email} \\
\end{tabular}% 
\fi
\vskip 0.3in minus 0.1in}}

\newcommand\startmain{\newpage\setcounter{page}{1}\par}
\newcommand\startopt{\newpage\centerline{\Large \bf Supplementary Material}}

\def\keywords#1{\vskip.2in\begin{minipage}[t]{1.4in}%
{\bf Keywords:}\end{minipage}\begin{minipage}[t]{4in}#1\end{minipage}}

\def\acknowledgements#1{\vskip.2in\subsubsection*{Acknowledgements}#1}

\def\repository#1{\vskip.2in\begin{minipage}[t]{1.4in}%
{\bf Repository:}\end{minipage}\begin{minipage}[t]{5in}\url{#1}\end{minipage}}

\def\spresentation#1{\vskip.2in\begin{minipage}[t]{1.4in}%
{\bf Short Presentation:}\end{minipage}\begin{minipage}[t]{5in}\url{#1}\end{minipage}}

\def\lpresentation#1{\vskip.2in\begin{minipage}[t]{1.4in}%
{\bf Long Presentation:}\end{minipage}\begin{minipage}[t]{5in}\url{#1}\end{minipage}}

\renewenvironment{abstract}{\vskip.075in\centerline{\large\bf
Abstract}\vspace{0.5ex}}{\par}

% sections with less space
\def\section{\@startsection {section}{1}{\z@}{-2.0ex plus
    -0.5ex minus -.2ex}{1.5ex plus 0.3ex
minus0.2ex}{\large\bf\raggedright}}

\def\subsection{\@startsection{subsection}{2}{\z@}{-1.8ex plus    
-0.5ex minus -.2ex}{0.8ex plus .2ex}{\normalsize\bf\raggedright}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{-1.5ex
plus      -0.5ex minus -.2ex}{0.5ex plus
.2ex}{\normalsize\bf\raggedright}}
\def\paragraph{\@startsection{paragraph}{4}{\z@}{1.5ex plus   
0.5ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subparagraph{\@startsection{subparagraph}{5}{\z@}{1.5ex plus 
  0.5ex minus .2ex}{-1em}{\normalsize\bf}}
\def\subsubsubsection{\vskip
5pt{\noindent\normalsize\rm\raggedright}}


% Footnotes
\footnotesep 6.65pt %
\skip\footins 9pt plus 4pt minus 2pt
\def\footnoterule{\kern-3pt \hrule width 12pc \kern 2.6pt }
\setcounter{footnote}{0}

% Lists and paragraphs
\parindent 0pt
\topsep 4pt plus 1pt minus 2pt
\partopsep 1pt plus 0.5pt minus 0.5pt
\itemsep 2pt plus 1pt minus 0.5pt
\parsep 2pt plus 1pt minus 0.5pt
\parskip .5pc


%\leftmargin2em 
\leftmargin3pc
\leftmargini\leftmargin \leftmarginii 2em
\leftmarginiii 1.5em \leftmarginiv 1.0em \leftmarginv .5em 

%\labelsep \labelsep 5pt

\def\@listi{\leftmargin\leftmargini}
\def\@listii{\leftmargin\leftmarginii
   \labelwidth\leftmarginii\advance\labelwidth-\labelsep
   \topsep 2pt plus 1pt minus 0.5pt
   \parsep 1pt plus 0.5pt minus 0.5pt
   \itemsep \parsep}
\def\@listiii{\leftmargin\leftmarginiii
    \labelwidth\leftmarginiii\advance\labelwidth-\labelsep
    \topsep 1pt plus 0.5pt minus 0.5pt 
    \parsep \z@ \partopsep 0.5pt plus 0pt minus 0.5pt
    \itemsep \topsep}
\def\@listiv{\leftmargin\leftmarginiv
     \labelwidth\leftmarginiv\advance\labelwidth-\labelsep}
\def\@listv{\leftmargin\leftmarginv
     \labelwidth\leftmarginv\advance\labelwidth-\labelsep}
\def\@listvi{\leftmargin\leftmarginvi
     \labelwidth\leftmarginvi\advance\labelwidth-\labelsep}

\abovedisplayskip 7pt plus2pt minus5pt%
\belowdisplayskip \abovedisplayskip
\abovedisplayshortskip  0pt plus3pt%
\belowdisplayshortskip  4pt plus3pt minus3pt%

% Less leading in most fonts (due to the narrow columns)
% The choices were between 1-pt and 1.5-pt leading
%\def\@normalsize{\@setsize\normalsize{11pt}\xpt\@xpt} % got rid of @ (MK)
\def\normalsize{\@setsize\normalsize{11pt}\xpt\@xpt}
\def\small{\@setsize\small{10pt}\ixpt\@ixpt}
\def\footnotesize{\@setsize\footnotesize{10pt}\ixpt\@ixpt}
\def\scriptsize{\@setsize\scriptsize{8pt}\viipt\@viipt}
\def\tiny{\@setsize\tiny{7pt}\vipt\@vipt}
\def\large{\@setsize\large{14pt}\xiipt\@xiipt}
\def\Large{\@setsize\Large{16pt}\xivpt\@xivpt}
\def\LARGE{\@setsize\LARGE{20pt}\xviipt\@xviipt}
\def\huge{\@setsize\huge{23pt}\xxpt\@xxpt}
\def\Huge{\@setsize\Huge{28pt}\xxvpt\@xxvpt}

\def\toptitlebar{\hrule height4pt\vskip .6cm\vskip-\parskip}

\def\bottomtitlebar{\vskip .7cm\vskip-\parskip\hrule height1pt\vskip
.09in} %
%Reduced second vskip to compensate for adding the strut in \@author

% Vertical Ruler
% This code is, largely, from the CVPR 2010 conference style file
% ----- define vruler
\makeatletter
\newbox\rldmrulerbox
\newcount\rldmrulercount
\newdimen\rldmruleroffset
\newdimen\cv@lineheight
\newdimen\cv@boxheight
\newbox\cv@tmpbox
\newcount\cv@refno
\newcount\cv@tot
% NUMBER with left flushed zeros  \fillzeros[<WIDTH>]<NUMBER>
\newcount\cv@tmpc@ \newcount\cv@tmpc
\def\fillzeros[#1]#2{\cv@tmpc@=#2\relax\ifnum\cv@tmpc@<0\cv@tmpc@=-\cv@tmpc@\fi
\cv@tmpc=1 %
\loop\ifnum\cv@tmpc@<10 \else \divide\cv@tmpc@ by 10 \advance\cv@tmpc by 1 \fi
   \ifnum\cv@tmpc@=10\relax\cv@tmpc@=11\relax\fi \ifnum\cv@tmpc@>10 \repeat
\ifnum#2<0\advance\cv@tmpc1\relax-\fi
\loop\ifnum\cv@tmpc<#1\relax0\advance\cv@tmpc1\relax\fi \ifnum\cv@tmpc<#1 \repeat
\cv@tmpc@=#2\relax\ifnum\cv@tmpc@<0\cv@tmpc@=-\cv@tmpc@\fi \relax\the\cv@tmpc@}%
% \makevruler[<SCALE>][<INITIAL_COUNT>][<STEP>][<DIGITS>][<HEIGHT>]
\def\makevruler[#1][#2][#3][#4][#5]{\begingroup\offinterlineskip
\textheight=#5\vbadness=10000\vfuzz=120ex\overfullrule=0pt%
\global\setbox\rldmrulerbox=\vbox to \textheight{%
{\parskip=0pt\hfuzz=150em\cv@boxheight=\textheight
\cv@lineheight=#1\global\rldmrulercount=#2%
\cv@tot\cv@boxheight\divide\cv@tot\cv@lineheight\advance\cv@tot2%
\cv@refno1\vskip-\cv@lineheight\vskip1ex%
\loop\setbox\cv@tmpbox=\hbox to0cm{{\rldmtenhv\hfil\fillzeros[#4]\rldmrulercount}}%
\ht\cv@tmpbox\cv@lineheight\dp\cv@tmpbox0pt\box\cv@tmpbox\break
\advance\cv@refno1\global\advance\rldmrulercount#3\relax
\ifnum\cv@refno<\cv@tot\repeat}}\endgroup}%
\makeatother
% ----- end of vruler

% \makevruler[<SCALE>][<INITIAL_COUNT>][<STEP>][<DIGITS>][<HEIGHT>]
\def\rldmruler#1{\makevruler[12pt][#1][1][3][0.993\textheight]\usebox{\rldmrulerbox}}
\AddToShipoutPicture{%
\ifrldmfinal\else
\rldmruleroffset=\textheight
\advance\rldmruleroffset by -3.7pt
  \color[rgb]{.7,.7,.7}
  \AtTextUpperLeft{%
    \put(\LenToUnit{-35pt},\LenToUnit{-\rldmruleroffset}){%left ruler
      \rldmruler{\rldmrulercount}}
  }
\fi
}
